window.addEventListener('load', function () {
  var menu = document.querySelector('.menu')
  menu.onclick = function (ev) {
    ev = ev || window.event
    var target = ev.target || ev.srcElement
    // 避免点到a标签，利用循环找到li
    while(target !== menu ){
      if(target.tagName.toLowerCase() == 'li'){
        for(var i = 0;i<menu.children.length;i++){
          menu.children[i].className=''
        }
        target.className = 'navActive';
          break;
      }
      target = target.parentNode;
  }
  }

})

